package com.kk.state;

import java.util.Random;

/**
 * @author o_o
 * @date 2022-06-21
 */
public class CanRaffle extends State {
    RaffleActivity activity;

    public CanRaffle(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deductMoney() {
        System.out.println("已经扣过积分，可以开始抽奖");

    }

    @Override
    public boolean raffle() {
        System.out.println("开始抽奖。。。");
        Random random = new Random();
        int i = random.nextInt(10);
        if (i == 0) {
            activity.setState(activity.getDispenseState());
            return true;
        }

        System.out.println("很遗憾，没有抽中奖品。");
        activity.setState(activity.getNoRaffleState());
        return false;
    }

    @Override
    public void dispensePrize() {
        System.out.println("没有中奖，不能发放奖品");

    }
}
